@echo off
cd %~dp0%..

call scripts\win_env.bat

set BUILD_DIR=build\win_build
set DEPLOY_DIR=build\win_deploy
set DEPLOY_PATH=%DEPLOY_DIR%\%DEPLOY_NAME%

echo Removing cache...
@REM rmdir /s/q %BUILD_DIR%
if exist %DEPLOY_DIR% (
    rmdir /s/q %DEPLOY_DIR%
)

echo Building...
cmake -B %BUILD_DIR%
cmake --build %BUILD_DIR% --config Release

echo Deploying...
mkdir %DEPLOY_PATH%
copy %BUILD_DIR%\src\Release\DBLParse.exe %DEPLOY_PATH%
copy %BUILD_DIR%\src\libcrypto-1_1-x64.dll %DEPLOY_PATH%
copy %BUILD_DIR%\src\libssl-1_1-x64.dll %DEPLOY_PATH%
windeployqt %DEPLOY_PATH%\DBLParse.exe --release --verbose 0

echo Compressing...
cd %DEPLOY_DIR%
@REM bc c -fmt:7z DBLParse.7z DBLParse
7z a %DEPLOY_NAME%.7z %DEPLOY_NAME% -mx9

echo Deploy successful!
